#include "serial.h"



Serial::Serial(QObject *parent) : QObject(parent)
{


}

QList<QSerialPortInfo> Serial::getAllSerial()
{
    QSerialPortInfo info;
    return info.availablePorts();
}

bool Serial::serialOpen(QString portname)
{
    device.setPortName(portname);//端口名
    device.setBaudRate(115200);
    return device.open(QIODevice::ReadWrite);
}

void Serial::sendCommand_weakup()
{
    uint8_t command[24] =
    {0x55,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x03,0xFD,0xD4,0x14,0x01,0x17,0x00};
    device.write((const char*)command,24);
}

void Serial::sendCommand_find()
{
    uint8_t command[11] =
    {0x00,0x00,0xFF,0x04,0xFC,0xD4,0x4A,0x01,0x00,0xE1,0x00};
    device.write((const char*)command,11);
}
